package com.niit.tsr.service;

import com.niit.tsr.bean.BorrowRecord;
import com.niit.tsr.repository.BorrowRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Transactional
@Service("BorrowService")
public class BorrowServiceImpl implements BorrowService {
    @Autowired
    private BorrowRepository borrowRepository;

    @Override
   public void borrow(BorrowRecord borrowRecord) {
      borrowRepository.save(borrowRecord);
   }

    @Override
    public List<BorrowRecord> findUserId(Integer user_id) {
        return (List<BorrowRecord>) borrowRepository.findUserId(user_id);
    }

    @Override
    public void deleteBorrowRecord(Integer borrow_id) {
        borrowRepository.deleteBorrowRecord(borrow_id);
    }

    @Override
    public void updateBorrowDateByBookId(Integer borrow_id) {
        borrowRepository.updateBorrowDateByBookId(borrow_id);
    }


}
